
import Home from "@/pages/Home";
import Register from "@/pages/Register";
import Login from "@/pages/Login";
import Search from "@/pages/Search";
import Detail from "@/pages/Detail";
import AddCartSuccess from "@/pages/AddCartSuccess";
import ShopCart from "@/pages/ShopCart";


export default
    [
        {
            path: "/shopcart",
            name: "shopcart",
            component: ShopCart,
        },
        {
            path: "/addcartsuccess",
            name: "addcartsuccess",
            component: AddCartSuccess,
        },
        {
            path: "/home",
            component: Home,
        },
        {
            path: "/detail/:skuId",
            component: Detail,
        },
        {
            name: "search",
            path: "/search/:keyword",
            component: Search,
            // props第一种写法,bool值，默认只传params参数
            // props:true

            // props第二种写法，对象形式，可以穿除了路径中新的参数
            // props:{a:1,b:2}

            /**
             * props第三种写法，函数形式，既可以传路由中参数，又可以传新的参数，路由中参数是通过$route获得
             * 但是一般不会为了简化路由参数获取的写法而用props，太大费周章了，还是直接router-link，然后用$router.获取
             * */
            // props:($route)=>{
            //    return {keyword:$route.params.keyword,k:$route.query.k,a:1,b:2}
            // }
            // 简写形式，函数体的大括号、return全给你去掉，在外谜案加个小括号()表明一个整体就代表return
            // props: ($route) => ({
            //   keyword: $route.params.keyword,
            //   k: $route.query.k,
            //   a: 1,
            //   b: 2,
            // }),
        },
        {
            path: "/login",
            component: Login,
        },
        {
            path: "/register",
            component: Register,
        },
        // 重定向，当前面都匹配不到的时候就走下面
        {
            path: "*",
            redirect: "/home",
        },
    ]
